//
//  AXHdzqJfWaterCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/5.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqJfWaterCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"


@implementation AXHdzqJfWaterCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.font = FONT_FOURTEEN;;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 进度条 */
    //进度条
    HWProgressView *progressView = [[HWProgressView alloc] initWithFrame:CGRectMake(220, 60, 100, 10)];
    progressView.progress += 0.5;
    [self.contentView addSubview:progressView];
    self.progressView = progressView;
    
    
    /** 进度条label */
    self.showProgressLabel = [[UILabel alloc]init];
    self.showProgressLabel.text = @"234/300";
    self.showProgressLabel.font = FONT_FOURTEEN;;
    self.showProgressLabel.textColor = COLOR_GREEN;
    [self.contentView addSubview:self.showProgressLabel];
    
    /** 价格 */
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.textColor = COLOR_ORG;
    self.priceLabel.font = FONT_FOURTEEN;
    self.priceLabel.text = @"2000积分";
    [self.contentView addSubview:self.priceLabel];
    
    /** 去支付*/
    self.buyButton = [[UIButton alloc]init];
    self.buyButton.titleLabel.font = FONT_FOURTEEN;;
    self.buyButton.backgroundColor = COLOR_ORG;
    [self.buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.buyButton setTitle:@"立即兑换" forState:UIControlStateNormal];
    [self.contentView addSubview:self.buyButton];
    
    
    
    
}

- (void)setlayout {
    
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .topSpaceToView(self.contentView, 10)
    .widthIs(120)
    .heightIs(120);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    
    /** 进度条label */
    self.showProgressLabel.sd_layout
    .leftSpaceToView(self.progressView, 10)
    .centerYEqualToView(self.progressView)
    .widthIs(80)
    .heightIs(20);
    
    /* 价格 **/
    self.priceLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.progressView,10)
    .heightIs(30);
    /** 买 */
    self.buyButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.progressView,10)
    .widthIs(70)
    .heightIs(30);
    
    
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.priceLabel bottomMargin:10];
    
}

@end
